home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / UVE138.ZIP / EXAMPLES.ZIP / MAP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-08-31  |  1.5 KB  |  80 lines

  1. {$A+,B-,D+,E+,F-,G+,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+}
  2. {$M 16384,0,655360}
  3.  
  4. {
  5. MAP.PAS
  6. Demonstrates     - PCX loading
  7.         - palette mapping
  8.         - translucency (transparency)
  9.  
  10. Notice sprite is loaded only once.  What changes are the map and transparency.
  11. }
  12.  
  13.  
  14. uses    crt,uve32;
  15.  
  16. const    maxspheres=5;
  17.  
  18. type    spheretype=record
  19.         x,y,
  20.         forcex,forcey:longint;
  21.     end;
  22.  
  23. var    sphere:array[1..maxspheres] of spheretype;
  24.  
  25. procedure init;
  26. var    i:integer;
  27. begin
  28.     ia_inituve;
  29.     ia_loadpcx(background,'wacky.pcx',255);
  30.     ia_loadspr('3ball.uvs',1);
  31.     ia_powerup;
  32.     ia_setpalette(pcxpal);
  33.     ia_setcycletime(40);
  34.     ia_makeshadowmap(pcxpal,70,maparray[1]);
  35.     ia_makeshadowmap(pcxpal,130,maparray[2]);
  36.     for i:=1 to maxspheres do with sphere[i] do begin
  37.         x:=longint(random(320))*256;
  38.         y:=longint(random(180))*256;
  39.         forcex:=(longint(random(10))-5)*256;
  40.         forcey:=(longint(random(10))-5)*256;
  41.         spr[i].n:=1;
  42.     end;
  43.     spr[2].map:=1;
  44.     spr[3].map:=1;
  45.     spr[3].transparent:=true;
  46.     spr[4].map:=2;
  47.     spr[5].map:=2;
  48.     spr[5].transparent:=true;
  49. end;
  50.  
  51. procedure deinit;
  52. begin
  53.     ia_shutdown;
  54.     halt;
  55. end;
  56.  
  57.  
  58. procedure movespheres;
  59. var    i:integer;
  60. begin
  61.     for i:=1 to maxspheres do with sphere[i] do begin
  62.         inc(x,forcex);
  63.         inc(y,forcey);
  64.         if (y>200*256) and (forcey>0) then
  65.             forcey:=-forcey
  66.             else inc(forcey,64);
  67.         if (x<0) and (forcex<0) then forcex:=-forcex;
  68.         if (x>320*256) and (forcex>0) then forcex:=-forcex;
  69.         ia_center(i,x div 256,y div 256,2);
  70.     end;
  71. end;
  72.  
  73. begin
  74.     init;
  75.     repeat
  76.         movespheres;
  77.         ia_doframe;
  78.     until keypressed;
  79.     deinit;
  80. end.